package test.niuke;

public class ChangLiangChi {
    public static void main(String[] args) {
        String s1 = "a";
        String s2 = "b";
        String s3 = "a"+"b";
        String s4 = s1+s2;
        String s5 = "ab";
        String s6 = s4.intern();
        System.out.println(s3 == s4); // false，因为s1+s2实际上是使用StringBuilder.append来完成，会生成不同的对象。
        System.out.println(s3 == s5);
        System.out.println(s3 == s6);

        System.out.println("-------------------");
        String str2 = new String("str2")+new String("02");
        String str1 = "str02";
        str2.intern();
        System.out.println(str2==str1);

        String str4 = new String("str")+new String("01");
        str4.intern();
        String str3 = "str01";
        System.out.println(str4==str3);
    }
}
